package com.example.designpatternproject.builder;

import android.content.Context;
import android.text.TextWatcher;
import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;

import androidx.annotation.IdRes;

/**
 * @ClassName: ImplEditNavigationBar
 * @Author: 史大拿
 * @CreateDate: 10/19/22$ 1:35 PM$
 * TODO
 */
public class ImplEditNavigationBar extends BaseNavigationBar {
    public ImplEditNavigationBar(BaseNavigationBar.Builder<?> builder) {
        super(builder);
    }

    public static class Builder extends BaseNavigationBar.Builder<ImplEditNavigationBar> {

        public Builder(Context context, int layoutId, ViewGroup parent) {
            super(context, layoutId, parent);
        }

        public Builder setOnTextChangedListener(@IdRes int id, TextWatcher textWatcher) {
            View view = findViewById(id);

            if (view instanceof EditText) {
                ((EditText) view).addTextChangedListener(textWatcher);
            } else {
                showToast("监听错误QaQ");
            }
            return this;
        }

        @Override
        ImplEditNavigationBar builder() {
            return new ImplEditNavigationBar(this);
        }
    }
}
